<?php

/**
 * PersonalInformation filter form base class.
 *
 * @package    ecrm
 * @subpackage filter
 * @author     Saul Santiago
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BasePersonalInformationFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'first_name'      => new sfWidgetFormFilterInput(),
      'last_name'       => new sfWidgetFormFilterInput(),
      'middle_name'     => new sfWidgetFormFilterInput(),
      'contact_no'      => new sfWidgetFormFilterInput(),
      'mobile_no'       => new sfWidgetFormFilterInput(),
      'address1'        => new sfWidgetFormFilterInput(),
      'street'          => new sfWidgetFormFilterInput(),
      'barangay'        => new sfWidgetFormFilterInput(),
      'city_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('City'), 'add_empty' => true)),
      'zip_code'        => new sfWidgetFormFilterInput(),
      'fax_no'          => new sfWidgetFormFilterInput(),
      'tin'             => new sfWidgetFormFilterInput(),
      'sss_gsis'        => new sfWidgetFormFilterInput(),
      'passport_no'     => new sfWidgetFormFilterInput(),
      'passport_expiry' => new sfWidgetFormFilterInput(),
      'citizenship'     => new sfWidgetFormFilterInput(),
      'civil_status'    => new sfWidgetFormFilterInput(),
      'spouse_name'     => new sfWidgetFormFilterInput(),
      'status'          => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'is_primary'      => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'title'           => new sfWidgetFormFilterInput(),
      'kids'            => new sfWidgetFormFilterInput(),
      'birthdate'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'created_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'first_name'      => new sfValidatorPass(array('required' => false)),
      'last_name'       => new sfValidatorPass(array('required' => false)),
      'middle_name'     => new sfValidatorPass(array('required' => false)),
      'contact_no'      => new sfValidatorPass(array('required' => false)),
      'mobile_no'       => new sfValidatorPass(array('required' => false)),
      'address1'        => new sfValidatorPass(array('required' => false)),
      'street'          => new sfValidatorPass(array('required' => false)),
      'barangay'        => new sfValidatorPass(array('required' => false)),
      'city_id'         => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('City'), 'column' => 'id')),
      'zip_code'        => new sfValidatorPass(array('required' => false)),
      'fax_no'          => new sfValidatorPass(array('required' => false)),
      'tin'             => new sfValidatorPass(array('required' => false)),
      'sss_gsis'        => new sfValidatorPass(array('required' => false)),
      'passport_no'     => new sfValidatorPass(array('required' => false)),
      'passport_expiry' => new sfValidatorPass(array('required' => false)),
      'citizenship'     => new sfValidatorPass(array('required' => false)),
      'civil_status'    => new sfValidatorPass(array('required' => false)),
      'spouse_name'     => new sfValidatorPass(array('required' => false)),
      'status'          => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'is_primary'      => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'title'           => new sfValidatorPass(array('required' => false)),
      'kids'            => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'birthdate'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'created_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('personal_information_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'PersonalInformation';
  }

  public function getFields()
  {
    return array(
      'id'              => 'Number',
      'first_name'      => 'Text',
      'last_name'       => 'Text',
      'middle_name'     => 'Text',
      'contact_no'      => 'Text',
      'mobile_no'       => 'Text',
      'address1'        => 'Text',
      'street'          => 'Text',
      'barangay'        => 'Text',
      'city_id'         => 'ForeignKey',
      'zip_code'        => 'Text',
      'fax_no'          => 'Text',
      'tin'             => 'Text',
      'sss_gsis'        => 'Text',
      'passport_no'     => 'Text',
      'passport_expiry' => 'Text',
      'citizenship'     => 'Text',
      'civil_status'    => 'Text',
      'spouse_name'     => 'Text',
      'status'          => 'Boolean',
      'is_primary'      => 'Boolean',
      'title'           => 'Text',
      'kids'            => 'Number',
      'birthdate'       => 'Date',
      'created_at'      => 'Date',
      'updated_at'      => 'Date',
    );
  }
}
